package com.etennis.controller;

import com.etennis.pojos.PageResult;
import com.etennis.pojos.ResponseResult;
import com.etennis.pojos.dto.web.ExchangePageQueryDTO;
import com.etennis.pojos.entity.Order;
import com.etennis.pojos.vo.web.ExchangeVO;
import com.etennis.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web/exchange")
@Slf4j
@Api(tags = "网页端-兑换管理接口")
public class ExchangeController {
    @Autowired
    IOrderService iOrderService;

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除兑换码")
    public ResponseResult delete(@PathVariable Long id){
        iOrderService.removeById(id);
        return ResponseResult.okResult();
    }

    @GetMapping("/page")
    @ApiOperation("分页展示兑换码")
    public ResponseResult<PageResult<ExchangeVO>> page(ExchangePageQueryDTO exchangePageQueryDTO){
        PageResult<ExchangeVO> page=iOrderService.pageCode(exchangePageQueryDTO);
        return ResponseResult.okResult(page);
    }

    @GetMapping("/status/{id}")
    @ApiOperation("兑换状态码")
    public ResponseResult status(@PathVariable Long id){

        iOrderService.stats(id);
        return ResponseResult.okResult();
    }


}
